import { getCollapse, getLanguage, getSize, setCollapse, setLanguage, setSize } from '@/utils/session'
import { defineStore } from 'pinia'

export interface AppState {
  size: string, // 字体
  language: string, // 国际化语言
  collapse: boolean // 左侧菜单栏折叠
}

export const useAppStore = defineStore('app', {
  state (): AppState {
    return {
      size: getSize(),
      language: getLanguage(),
      collapse: getCollapse()
    }
  },

  actions: {
    SetSize (size: string) {
      setSize(size)
      this.size = size
    },
    SetLanguage (lang: string) {
      setLanguage(lang)
      this.language = lang
    },
    SetCollapse (collapse: boolean) {
      setCollapse(collapse)
      this.collapse = collapse
    }
  }
})
